package NewCoder;

public class BM73 {
    public int getLongestPalindrome (String A) {
        // write code here
        int len=A.length();
        if(len<2) return A.length();
        boolean[][] dp=new boolean[len][len];
        int maxLen=1;
        for(int i=0;i<len;i++){
            dp[i][i]=true;
        }
        char[] ch=A.toCharArray();
        for(int j=1;j<len;j++){
            for(int i=0;i<j;i++){
                if(ch[i]!=ch[j]){
                    dp[i][j]=false;
                }else if(j-i<3){
                    dp[i][j]=true;
                }else{
                    dp[i][j]=dp[i+1][j-1];
                }
                if(dp[i][j] && j-i+1>maxLen){
                    maxLen=j-i+1;
                }
            }
        }
        return maxLen;
    }
}
